package org.ihelpuoo.io;

import java.io.InputStreamReader;
import java.io.Reader;

import junit.framework.TestCase;

public class BOBReaderTest extends TestCase
{
	public void test1() throws Exception
	{
		String s = "ABCDE";
		String expect = "T" + s;
		Reader r = new BOBReader(new InputStreamReader(new CharInputStream(s)),(int)expect
				.charAt(0));
		char[] cbuf = new char[s.length() + 1];
		r.read(cbuf,0,s.length() + 1);
		r.close();
		assertEquals(expect,String.valueOf(cbuf));
	}

	public void test2() throws Exception
	{
		String s = "ABCDE";
		String expect = "T" + s;
		Reader r = new BOBReader(new InputStreamReader(new CharInputStream(s)),(int)expect
				.charAt(0));
		for(int i=0;i<expect.length();i++)
		{
			assertEquals(expect.charAt(i),(char)r.read());
		}
		r.close();
	}
}
